home *** CD-ROM | disk | FTP | other *** search
/ Windows Expert / Windows Expert.iso / windownt / uupc11ys.zip / LIB / MKDIR.C < prev    next >
C/C++ Source or Header  |  1993-04-10  |  3KB  |  92 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    m k d i r . c                                                   */
  3. /*                                                                    */
  4. /*    Support routines for UUPC/extended                              */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*    Changes Copyright (c) 1989 by Andrew H. Derbyshire.             */
  9. /*                                                                    */
  10. /*    Changes Copyright (c) 1990-1993 by Kendra Electronic            */
  11. /*    Wonderworks.                                                    */
  12. /*                                                                    */
  13. /*    All rights reserved except those explicitly granted by the      */
  14. /*    UUPC/extended license agreement.                                */
  15. /*--------------------------------------------------------------------*/
  16.  
  17. /*--------------------------------------------------------------------*/
  18. /*                          RCS Information                           */
  19. /*--------------------------------------------------------------------*/
  20.  
  21. /*
  22.  *    $Id: MKDIR.C 1.4 1993/04/11 00:31:31 dmwatt Exp $
  23.  *
  24.  *    Revision history:
  25.  *    $Log: MKDIR.C $
  26.  *     Revision 1.4  1993/04/11  00:31:31  dmwatt
  27.  *     Global edits for year, TEXT, etc.
  28.  *
  29.  *     Revision 1.3  1993/03/24  01:57:30  ahd
  30.  *     Delete unneeded currentfile()
  31.  *
  32.  */
  33.  
  34. #include <stdio.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37. #include <time.h>
  38.  
  39. #ifdef __GNUC__
  40. #include <os2.h>
  41. #else
  42. #include <direct.h>
  43. #endif
  44.  
  45. /*--------------------------------------------------------------------*/
  46. /*                    UUPC/extended include files                     */
  47. /*--------------------------------------------------------------------*/
  48.  
  49. #include "lib.h"
  50.  
  51. /*--------------------------------------------------------------------*/
  52. /*    M K D I R                                                       */
  53. /*                                                                    */
  54. /*    Like mkdir() but create intermediate directories as well        */
  55. /*--------------------------------------------------------------------*/
  56.  
  57. int MKDIR(const char *inpath)
  58. {
  59.    char *cp;
  60.    char *path;
  61.  
  62.    if (*inpath == '\0')
  63.       return 0;
  64.  
  65.    cp = path = normalize(inpath );
  66.  
  67.  
  68. /*--------------------------------------------------------------------*/
  69. /*        See if we need to make any intermediate directories         */
  70. /*--------------------------------------------------------------------*/
  71.  
  72.    cp = path ;
  73.    while ((cp = strchr(cp, '/')) != nil(char)) {
  74.       *cp = '\0';
  75.  
  76. #ifndef __GNUC__
  77.       mkdir(path);
  78. #else
  79.       DosCreateDir( path, 0);
  80. #endif
  81.       *cp = '/';
  82.       cp++;
  83.    }
  84.  
  85. /*--------------------------------------------------------------------*/
  86. /*                           Make last dir                            */
  87. /*--------------------------------------------------------------------*/
  88.  
  89.    return mkdir(inpath);
  90.  
  91. } /*MKDIR*/
  92.